﻿using System.Collections.Generic;
using CryptoFile.Library.LongArithmetic;
using NUnit.Framework;

namespace CryptoFile.Library.Tests {
	static class TestHelper {
		public static void CheckNumber(BigNumber number, params int[] expectedNumbers) {
			var numbers = number.Numbers;
			Assert.AreEqual(expectedNumbers.Length, numbers.Count,
			                "Разрядность чисел не совпадает\n" + GetMessage(expectedNumbers, number.Numbers));
			for (var i = 0; i < expectedNumbers.Length; ++i) {
				if (expectedNumbers[i] != numbers[i]) {
					Assert.AreEqual(expectedNumbers[i], numbers[i],
					                "Ошибка в разряде: " + i + "\n" + GetMessage(expectedNumbers, number.Numbers));
				}
			}
		}

		private static string GetMessage(IList<int> expectedNumber, IList<int> actualNumber) {
			var message = string.Format("\nExpectedNumber[{0}]: ", expectedNumber.Count);
			for (var i = 0; i < expectedNumber.Count; ++i) {
				message += expectedNumber[i] + ", ";
			}
			message += "\n";
			message += string.Format("ActualNumber[{0}]: ", actualNumber.Count);
			for (var i = 0; i < actualNumber.Count; ++i) {
				message += actualNumber[i] + ", ";
			}
			message += "\n";
			return message;
		}
	}
}